package com.japhet.stripesdemo.conf;

import com.stripe.Stripe;
import com.xiaoleilu.hutool.util.StrUtil;
import io.github.cdimascio.dotenv.Dotenv;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.event.*;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.RequestHandledEvent;

/**
 * 这是一个示例， 真正用的时候， 会再每个服务中单独去写启动预热和关闭清理的相关逻辑
 */
@Component
@Slf4j
public class AppStartAndStopNotify implements CommandLineRunner {

    @Autowired
    private Dotenv dotenv;
    @Override
    public void run(String... args) throws Exception {

        Stripe.apiKey = dotenv.get("STRIPE_SECRET_KEY");
        log.info(StrUtil.format("设置Stripe.apiKey成功：{}", Stripe.apiKey));
        log.info("应用启动成功");
    }
}

